Array.prototype.MyforEach = function (callback, thisArg) {
    if (typeof callback !== 'function') {
        throw new TypeError(callback + ' is not a function');
    }

    if (this == undefined) {
        throw new TypeError('this is null or not defined');
    }

    const O = Object(this);
    let len = O.length;
    for (let i = 0; i < len; i++) {
        if (i in O) {
            callback.call(thisArg, O[i], i, this);
        }
    }

}

const array1 = ['a', 'b', 'c'];

array1.MyforEach(element => console.log(element));
